<template>
  <Row type="flex" justify="space-between">
    <Col>
      <div class="t_list">
        <p class="t_tl">证书编号</p>
        <p>{{recordDetail?.safetyNo}}</p>
      </div>
    </Col>
    <Col>
      <div class="t_list">
        <p class="t_tl">发证日期</p>
        <p>{{parseTime(recordDetail?.approveDate) }}</p>
      </div>
    </Col>
    <Col>
      <div class="t_list">
        <p class="t_tl">有效期</p>
        <p>{{ parseTime(recordDetail?.safetyEdate) }}</p>
      </div>
    </Col>
    <Col flex="100%">
      <div class="t_list" :style="{width:'100%'}">
        <p class="t_tl">发证机关</p>
        <p>{{recordDetail?.safetyApproveUnitName}}</p>
      </div>
    </Col>
  </Row>
</template>
<script lang="ts">
import {defineComponent, inject, onMounted, ref } from 'vue';
import {Row, Col } from 'ant-design-vue';
import { getCorpSafetyApi  } from '/@/api/foreign';
import { parseTime } from '/@/utils';

interface model {
  approveDate?: string;//	批准日期	string(date-time)
  permitScope?: string;//	许可范围	string
  safetyApproveUnitName?: string;//	批准机关名称	string
  safetyEdate?: number;//	有效日期止	string(date-time)
  safetyId?: string;//	id	string
  safetyNo?: string;//	安许证书号	string
  safetyState	?: string;//状态	string
  safetyStateReason?: string;//	原因
}

export default defineComponent({
  components: { Row, Col
  },
  setup() {
    const corpId = inject('corpId') as string;
    const recordDetail = ref<model>({})
    const changeHandler = () => {
      getCorpSafetyApi( { corpId }).then( ({success,data}) => {
        if(success){
          let { records } = data;
          if(records.length){
            recordDetail.value =records[0]
          }

        }
      })
    }

    onMounted(changeHandler)

    return {
      changeHandler ,recordDetail , parseTime
    }
  },
})
</script>

<style lang="less" scoped>


.t_list{
  width: 380px;
  padding: 18px;
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  background: #F3F3F3;

  .t_tl {
    font-size: 16px;
    font-weight: 600;
  }

  p {
    height: 22px;
    margin: 5px 0;
  }

}
</style>

